﻿using MaterialDesignColors;
using MaterialDesignThemes.Wpf;
using PDFDesign.Command;
using System.Collections.Generic;
using System.Windows.Input;
using PDFDesign.Properties;

namespace PDFDesign.ViewModel
{
    public class PaletteViewModel : BaseViewModel
    {
        public PaletteViewModel()
        {
            Swatches = new SwatchesProvider().Swatches;
        }
        public IEnumerable<Swatch> Swatches { get; }

        public ICommand ApplyPrimaryCommand { get; } = new AnotherCommand(o => ApplyPrimary((Swatch)o));

        private static void ApplyPrimary(Swatch swatch)
        {
            new PaletteHelper().ReplacePrimaryColor(swatch);
            Settings.Default.PrimaryColor = swatch.Name;
            Settings.Default.Save();
        }

        public ICommand ApplyAccentCommand { get; } = new AnotherCommand(o => ApplyAccent((Swatch)o));

        private static void ApplyAccent(Swatch swatch)
        {
            new PaletteHelper().ReplaceAccentColor(swatch);
            Settings.Default.AccentColor = swatch.Name;
            Settings.Default.Save();
        }
    }
}
